import { onMounted } from "vue";
/**
 * 左动画
 * @param dom 传入的节点dom
 * @param dom_title 传产生动画的dom元素
 */
const show = (dom: any, dom_title: any): void => {
    onMounted(() => {
        window.addEventListener("scroll", (e) => {
            let gundo: number =
                document.documentElement.scrollTop || document.body.scrollTop; // 获取滚动条离窗体高度差多少
            let aboust: number = document.querySelector(
                dom
            ).offsetTop; //传进来的那个dom距离顶部的高度
            const element = document.querySelector(dom_title);
            if (gundo >= aboust / 1.5) {
                element.classList.remove("animate__animated", "animate__backOutLeft");
                element.classList.add("animate__animated", "animate__backInLeft");
            } else {
                element.classList.remove("animate__animated", "animate__flip");
                element.classList.add("animate__animated", "animate__backOutLeft");
            }
        });
    })

}
export default show